package com.wuzheng.wisgo.sanitation.cloud.controller.vehicle;


import com.wuzheng.wisgo.sanitation.cloud.repository.entity.vehicle.BaVehicle;
import com.wuzheng.wisgo.sanitation.cloud.model.vehicle.BaVehicleCriteria;
import com.wuzheng.wisgo.sanitation.cloud.service.vehicle.VehicleService;
import com.wuzheng.wisgo.sanitation.framework.base.controller.BaseController;
import com.wuzheng.wisgo.sanitation.framework.core.protocol.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author：sp
 * @date：Created in 2019-10-08
 * @description：车辆信息控制器
 * @modified By：
 * @version: 1.0
 */
@RestController
@RequestMapping("/vehicle")
@Api(value = "VehicleCtrl", tags = "车辆信息接口")
public class VehicleCtrl extends BaseController {

    @Autowired
    private VehicleService vehicleService;

    /**
     * 获取车辆信息列表
     */
    @PostMapping(value = "/list")
    @ApiOperation(value = "获取车辆信息列表")
    @ResponseBody
    public Result<BaVehicle> list(@RequestBody BaVehicleCriteria baVehicle) {
        return this.success(vehicleService.selectPage(baVehicle));
    }


    /**
     * 新增车辆信息
     */
    @PostMapping(value = "/add")
    @ApiOperation(value = "新增车辆信息")
    public Result<String> add(BaVehicle vehicle) {
        vehicleService.insert(vehicle);
        return this.success();
    }

    /**
     * 删除车辆信息
     */
    @PostMapping(value = "/delete/{id}")
    @ApiOperation(value = "删除车辆信息")
    public Result<String> delete(@PathVariable("id") Long id) {
        vehicleService.deleteById(id);
        return this.success();
    }

    /**
     * 修改车辆信息
     */
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改车辆信息")
    public Result<String> update(BaVehicle vehicle) {
        vehicleService.updateById(vehicle);
        return this.success();
    }

    /**
     * 获取车辆信息
     */
    @GetMapping(value = "/get/{id}")
    @ApiOperation(value = "获取车辆信息")
    public Result<BaVehicle> get(@PathVariable("id") Long id) {
        return this.success(vehicleService.selectById(id));
    }
}

